﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace ErhuBlog.IRepository
{
    public interface IBaseRepository<TEntity> where TEntity:class
    {
       /// <summary>
       /// 单表查询
       /// </summary>
       /// <param name="predicate"></param>
       /// <returns></returns>
        List<TEntity> QueryWhere(Expression<Func<TEntity, bool>> predicate);
        /// <summary>
        /// 多表查询
        /// </summary>
        /// <param name="predicate"></param>
        /// <param name="tableNames"></param>
        /// <returns></returns>
        List<TEntity> QueryJoin(Expression<Func<TEntity, bool>> predicate ,string[] tableNames);

        List<TEntity> QueryOrderBy<Tkey>(Expression<Func<TEntity,bool>> predicate, Expression<Func<TEntity,Tkey>> keySelector, bool IsQueryOrderBy);

        List<TEntity> QueryByPage<TKey>(int pageIndex, int pagesize, out int rowcount, Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TKey>> keySelector, bool IsQueryOrderBy);

        void Edit(TEntity model, string[] propertys);
        void Edit(TEntity model);
        void Delete(TEntity model, bool isadded);
        void Add(TEntity model);
        int SaveChanges();
        List<TResult> RunProc<TResult>(string sql, params object[] pamrs);

    }
}
